package com.tiantian.quanminxiu.utils.face;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;


import com.tiantian.quanminxiu.R;

import java.util.ArrayList;
import java.util.List;

public class FaceAdapter extends BaseAdapter {
	List<FaceModel> list = new ArrayList<FaceModel>();
	Context context;

	public FaceAdapter(Context _context, List<FaceModel> _list) {
		list = _list;
		context = _context;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@SuppressLint("NewApi")
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		viewHolder holder;
		if (convertView == null) {
			convertView = LayoutInflater.from(context).inflate(
					R.layout.layout_gv_face, null);
			holder=new viewHolder();
			holder.iv_f = (ImageView) convertView.findViewById(R.id.iv_f);
			convertView.setTag(holder);
		}else{
			holder=(viewHolder) convertView.getTag();
		}
		holder.iv_f.setImageResource(list.get(position).getFaceId());
		return convertView;
	}
	class viewHolder{
		ImageView iv_f;
	}

}
